import { axios } from '@/utils/request'
import api from './apiUrl'

export function GetContractList (parameter) {
  return axios({
    url: api.Contracts,
    method: 'post',
    data: parameter
  })
}

export function SaveContract (parameter) {
  return axios({
    url: api.Contract,
    method: 'post',
    data: parameter
  })
}

export function DelContract (parameter) {
  return axios({
    url: api.Contract,
    method: 'delete',
    data: parameter
  })
}

export function ExportContract (parameter) {
  return axios({
    url: api.Contract + '/export',
    method: 'post',
    data: parameter,
    responseType: 'blob'
  })
}

export function ImportContract (parameter) {
  return axios({
    url: api.Contract + '/import',
    method: 'post',
    data: parameter,
    headers: {
      'content-Type': 'multipart/form-data'
    }
  })
}

export function GetCertificateList (parameter) {
  return axios({
    url: api.Certificates,
    method: 'post',
    data: parameter
  })
}

export function SaveCertificate (parameter) {
  return axios({
    url: api.Certificate,
    method: 'post',
    data: parameter
  })
}

export function DelCertificate (parameter) {
  return axios({
    url: api.Certificate,
    method: 'delete',
    data: parameter
  })
}

export function ExportCertificate (parameter) {
  return axios({
    url: api.Certificate + '/export',
    method: 'post',
    data: parameter,
    responseType: 'blob'
  })
}

export function ImportCertificate (parameter) {
  return axios({
    url: api.Certificate + '/import',
    method: 'post',
    data: parameter,
    headers: {
      'content-Type': 'multipart/form-data'
    }
  })
}

export function Attachment (parameter) {
  return axios({
    url: api.Attachment + '/' + parameter.attachmentType + '/' + parameter.id,
    method: 'get'
  })
}
export function Upload (parameter) {
  return axios({
    url: api.Upload,
    method: 'post',
    data: parameter,
    headers: {
      'content-Type': 'multipart/form-data'
    }
  })
}
export function AttachmentDelete (parameter) {
  return axios({
    url: api.Attachment,
    data: parameter,
    method: 'delete'
  })
}
